﻿<Page x:Class="PasswordProvider.View.EnterPasswordPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:lib="clr-namespace:PasswordProvider.View.Library"
    Title="{Binding DisplayName}"
    ToolTip="{Binding ToolTip}"
    FocusManager.FocusedElement="{Binding ElementName=passwordBox}"
    >
    <Page.Resources>
        <Style x:Key="attentionBorder" TargetType="Border">
            <Style.Resources>
                <Storyboard x:Key="animateColor" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                    <ColorAnimation From="Transparent" To="Yellow" AutoReverse="True" RepeatBehavior="Forever" Duration="0:0:2" />
                </Storyboard>
            </Style.Resources>            
            <Style.Triggers>
              <DataTrigger Binding="{Binding ShowAttentionGetter}" Value="True" >
                    <Setter Property="BorderThickness" Value="6"/>
                    <Setter Property="BorderBrush" Value="Transparent" />
                    <DataTrigger.EnterActions>                       
                        <BeginStoryboard Name="animateBeginStoryboard" Storyboard="{StaticResource animateColor}" />                                                                             
                    </DataTrigger.EnterActions>                    
                </DataTrigger>
                <EventTrigger RoutedEvent="KeyDown">
                    <StopStoryboard BeginStoryboardName="animateBeginStoryboard" />
                </EventTrigger>
            </Style.Triggers>            
        </Style>
               
    </Page.Resources>
    <Border >
    <Grid Height="Auto" Width="Auto">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Border Grid.Row="1" Style="{StaticResource attentionBorder}" >
            <StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Margin="5,5,5,10">
                <TextBlock HorizontalAlignment="Left"                           
		            Text="{Binding Password.DisplayName}" 
		            TextAlignment="Left" Margin="10,0,0,5" />
                <lib:BindablePasswordBox x:Name="passwordBox" HorizontalAlignment="Stretch" Margin="10,0" 
                                         SecurePassword="{Binding Password.Password, Mode=OneWayToSource}"/>
                
            </StackPanel>
        </Border>
        <TextBlock Grid.Row="2" Visibility="{Binding Warning.Visibility}"
			   Text="{Binding Warning.DisplayName}"
			   Foreground="Red" HorizontalAlignment="Center" VerticalAlignment="Top" />
        <Button Grid.Row="3" Width="60" IsDefault="True" 
                HorizontalAlignment="Right" Margin="10" VerticalAlignment="Bottom"
                Command="{Binding OkCommand.Command}"
                Content="{Binding OkCommand.DisplayName}"
                ToolTip="{Binding OkCommand.ToolTip}"
                />
        

        </Grid>   
    </Border>

</Page>
